<?php
/*********************************************
 *  CPG Dragonfly™ CMS
 *********************************************
	Copyright © since 2010 by CPG-Nuke Dev Team
	http://dragonflycms.org

	Dragonfly is released under the terms and conditions
	of the GNU GPL version 2 or any later version
*/

namespace Poodle;

class DateTime extends \DateTime
{
	function __construct($time=null, $timezone=null)
	{
		if ($time instanceof \DateTime) {
			if (!$timezone) { $timezone = $time->getTimezone(); }
			$time = $time->getTimestamp();
		}
		if (is_int($time) || is_float($time) || (ctype_digit($time) && 11>strlen($time) && 20380119<$time)) {
			$time = '@'.(int)$time;
		}
		// DateTime::__construct() expects parameter 2 to be DateTimeZone, null given
		// Bug #52063, fixed in 5.3.6
		if ($timezone) {
			if (!($timezone instanceof \DateTimeZone)) {
				$timezone = new \DateTimeZone($timezone);
			}
			parent::__construct($time, $timezone);
			if ('@'===$time[0]) {
				parent::setTimezone($timezone); // Else timezone is +00:00
			}
		} else {
			parent::__construct($time);
		}
	}
}

class Date extends DateTime {}
class Time extends DateTime {}
class Timestamp extends DateTime {}
